package it.traveldream.utils;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class CalendarUtils {
	
	public enum WeekDay { 
		MONDAY("Monday"), 
		TUESDAY("Tuesday"), 
		WEDNESDAY("Wednesday"), 
		THURSDAY("Thursday"), 
		FRIDAY("Friday"), 
		SATURDAY("Saturday"), 
		SUNDAY("Sunday");
		
		protected String name;
		WeekDay(String name){
			this.name = name;
		}
		@Override
		public String toString(){
			return this.name;
		}
	};
	
	public static List<WeekDay> getDaysofWeek() {
		ArrayList<WeekDay> days = new ArrayList<>();
		for (WeekDay day : WeekDay.values()){
			days.add(day);
		}
		
		return days;
	}
	
	public static long daysBetween(Calendar startDate, Calendar endDate) {  
		if (startDate.after(endDate))
			throw new IllegalArgumentException("startDate must preceed endDate");
		
		Calendar date = (Calendar) startDate.clone();  
		long daysBetween = 0;  
		while (date.before(endDate)) {  
		    date.add(Calendar.DAY_OF_MONTH, 1);  
		    daysBetween++;  
		}  
		return daysBetween;  
	}  
}
